<?php
/**
 * Created by PhpStorm.
 * User: 明哲
 * Date: 2016/6/3
 * Time: 15:12
 */
include('../../config.php');

$action = $_GET['action'];
$id = $_GET['id'];

switch ($action) {
    default:
        $row = $mysql->query("select *  from `ad` where `id`='{$id}'");
        if($row){
            echo json_encode($row[0],true);
        }else{
            echo 0;
        };
        break;
    case 'del' :
        $rows = $mysql->query("delete from `ad` where `id`='{$id}'");
        echo 1;
        break;
    case 'update' :
        $type = $_GET['type'];
        $img = $_GET['img'];
        $title = $_GET['title'];
        $detail = $_GET['detail'];
        $url = $_GET['url'];
        $rows = $mysql->query("update `ad` set `type`='{$type}',`img`='{$img}',`title`='{$title}',`detail`='{$detail}',`url`='{$url}' where `id`='{$id}'");
        if(!$rows){
            echo 1;
        }else{
            echo 0;
        }
        break;

}